package model

import (
	"gorm.io/gorm"
	"member_srv/basic/config"
	"time"
)

type Like struct {
	Id        uint32         `gorm:"column:id;type:int UNSIGNED;primaryKey;not null;" json:"id"`
	UserId    int32          `gorm:"column:user_id;type:int;not null;" json:"user_id"`
	Video     int32          `gorm:"column:video;type:int;not null;" json:"video"`
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (l *Like) TableName() string {
	return "like"
}

func (l *Like) AddLike() error {
	return config.DB.Create(&l).Error
}

func (l *Like) DeleteLike() error {
	return config.DB.Delete(&l).Error
}
